<template>
    <view class="content">
        <view class="box" v-for="(item, index) in list" :key="index">
			<view class="item">
				<view class="item-left">健康卡</view>
				<view class="item-right">
					<view class="u-flex-1">{{item.cards.nickname}}</view>
					<view class="sta">{{item.status_txt}}</view>
					<!-- <view class="sta sta2">挂号失败</view> -->
				</view>
			</view>
			<view class="item">
				<view class="item-left">预约医院</view>
				<view class="item-right">{{item.hospital}}</view>
			</view>
			<view class="item">
				<view class="item-left">预约科室</view>
				<view class="item-right">{{item.department}}</view>
			</view>
			<view class="item">
				<view class="item-left">预约医生</view>
				<view class="item-right">{{item.doctor}}</view>
			</view>
			<view class="item">
				<view class="item-left">预约时间段</view>
				<view class="item-right">{{item.begin_date}} 到 {{item.end_date}} </view>
			</view>
			<view class="down" v-if="item.reason">
				失败原因：{{item.reason}}
			</view>
		</view>
		
		<view style="height: 94rpx;padding-top: 30rpx;">
		    <u-loadmore :status="status" v-if="status != 'loadmore'" />
		</view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                status: 'loadmore', //是否显示没有更多了
                page: 1,
                list: [],
            };
        },
        onLoad() {
            this.getList()
        },
		onReachBottom() {
			if(this.page == 1){return}
			this.getList()
		},
        methods: {
            getList() {
            	if (this.status == 'nomore') return;
            	this.status = 'loading';
            	this.$ajax('get_registers', {
                    userToken: this.$getSync('userToken'),
                    page: this.page,
                    limit: 10,
                }).then(ret => {
            		if (ret.status == 0) {
                        if (ret.data.length > 0) {
                        	this.list = this.list.concat(ret.data);
                        	this.page++;
                        	this.status = 'loadmore'
                        } else {
                        	this.status = 'nomore'
                        }
            		} else {
            			this.$toast(ret.message);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    page{
        background-color: #f5f5f5;
    }
	.content{
		padding: 20rpx;
	}
	.box{
		padding: 35rpx 30rpx;
		margin-bottom: 20rpx;
		background-color: #fff;
		border-radius: 20rpx;
		font-size: 26rpx;
	}
	.item{
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding-bottom: 15rpx;
	}
	.item:last-child{
		padding-bottom: 0;
	}
	.item-left{
		width: 170rpx;
		color: #a6a6a6;
	}
	.item-right{
		flex: 1;
		display: flex;
		justify-content: space-between;
		align-items: center;
		word-break: break-all;
		white-space: pre-line;
	}
	.sta{
		padding: 6rpx 8rpx;
		border-radius: 4rpx;
		margin-left: 15rpx;
		font-size: 22rpx;
		color: #01b6bc;
		background-color: #e8f8f9;
	}
	.sta2{
		color: #fe8928;
		background-color: #fff2e8;
	}
	.down{
		color: #fe8928;
		background-color: #fff2e8;
		padding: 12rpx 20rpx;
		border-radius: 6rpx;
		word-break: break-all;
		white-space: pre-line;
	}
	

</style>
